<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>管理信息系统课程设计 | MISP</title>
    <#include "/inc/head.ftl"/>
    <@head/>
</head>

<body>
    <div id="wrapper">
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel-body">
                        <button id="btn-rooms" type="button" class="btn btn-success">查看分配房号</button>
                        <button id="btn-addRoom" type="button" class="btn btn-success">分配房间</button>
                    </div>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">订单列表</div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-borderdetailed table-hover" id="list">
                                <thead>
                                    <tr>
                                        <th>Id</th>
                                        <th>房间类型Id</th>
                                        <th>房间类型</th>
                                        <th>数量</th>
                                        <th>单价</th>

                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
    <!-- Page-Scripts  -->
    <script>
          $(document).ready(function() {
              var id = ${(orderList.id)!};
            	var table = $('#list').DataTable({   //此处list与页面table的id相同
                	ajax: '${contextPath}/orderList/detail?id=' + id,
                	language: {
            			"url": "${contextPath}/vendor/datatables/i18n/Chinese.json"   //datatables国际化
        			}, 
                    columns: [
                         {data: "id","visible" : false},
                         {data: "roomTypeId","visible" : false},
                        {data: "typeName"},
                        {data: "qty"},
                        {data: "price"}
                        /* {data: "seatName"}, */
                    ],
                   responsive: true,
                   select: true //datatables select 插件
                });
              /* 修改房间按钮 */
              $('#btn-rooms').click(function() {
                  layer.open({
                      type: 2,
                      title: "修改房间",
                      area: ['400px', '350px'],
                      fixed: false, //不固定
                      maxmin: true,
                      content: '${contextPath}/orderDetailRoom/view_eachDetailRoom?orderListId=' + id,
                      end: function(index) {
                          table.ajax.reload();
                      }
                  });
              });
              /* 分配房间按钮 */
              $('#btn-addRoom').click(function() {
                  var rowData = table.rows({
                      selected: true
                  }).data().toArray();
                  if (rowData.length == 1) {
                      var id = rowData[0].roomTypeId;
                      var orderListId = ${(orderList.id)!};
                  layer.open({
                      type: 2,
                      title: "修改房间",
                      area: ['400px', '480px'],
                      fixed: false, //不固定
                      maxmin: true,
                      content: '${contextPath}/cart/view_addRoom?roomTypeId=' + id + "&orderListId=" + orderListId,
                      end: function(index) {
                          table.ajax.reload();
                      }
                  });
                  } else {
                      layer.msg('请选择一行!', {
                          time: 1000,
                          icon: 7
                      }); //layer弹出层，1000代表1秒后关闭。7为图标编号
                  }
              });


            
            

            
            
       

        });
    </script>
</body>

</html>